package com.stars.pao.aicloud.Tasks;


import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.stars.pao.aicloud.entity.User;
import com.stars.pao.aicloud.service.IUserService;
import com.xxl.job.core.handler.annotation.XxlJob;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class TimedTask {
    @Resource
    private IUserService userService;

    @Value("${system.user.usercount}")
    private int userCount;

    /**
     * 每日定时任务 重置用户使用次数定时任务
     */
    @XxlJob("resetUserUserCount")
    public void resetUserUserCount() {
        UpdateWrapper<User> updateWrapper = new UpdateWrapper<>();
        updateWrapper.set("usercount", userCount);
        if(!userService.update(updateWrapper)) {
            // todo: 调用通知中心相关负责人去排查和解决该问题
        }
    }
}
